import isString from 'src/utils/isString'
let prefix = '/shop/rest'
const origin = {
  dev: 'https://fkxuexi.top'
}
if (process.env.NODE_ENV === 'development') {
  prefix = origin.dev + prefix
}

const API = {
  Home: {
    Banners: '/carousel/carouel/list',
    Categories: '/carousel/category/list',
    SubCategories: '/home/category/more',
    Products: '/home/goods/list',
    Product: '/home/goods/detail'
  }
}

const addPrefix = function (uri, head) {
  if (isString(uri)) {
    return head + uri
  }
  for (let key in uri) {
    if (uri.hasOwnProperty(key)) {
      uri[key] = addPrefix(uri[key], head)
    }
  }
  return uri
}
addPrefix(API, prefix)
Object.freeze(API)
export default API
